home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat3 / exec.3 < prev    next >
Encoding:
Text File  |  1993-03-03  |  4.6 KB  |  133 lines

  1.  
  2.  
  3.  
  4. EXEC(3)             MINTLIB LIBRARY FUNCTIONS             EXEC(3)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        execl,  execv,  execle, execlp, execve, execvp - execute a
  9.        file
  10.  
  11. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  12.        #include <unistd.h>
  13.  
  14.        int execl(char *path, ...);
  15.  
  16.        int execv(char *path, char *argv[]);
  17.  
  18.        int execle(char *path, ...);
  19.  
  20.        int execlp(char *file, ...);
  21.  
  22.        int execve(char *path, char *argv[], char *envp[]);
  23.  
  24.        int execvp(char *file, char *argv[]);
  25.  
  26. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  27.        These routines transform the calling process  into  a  new
  28.        process.   The  program  indicated  by `path' or `file' is
  29.        loaded, then run.  There can be no return from a succesful
  30.        exec call.
  31.  
  32.        These calls differ in the following ways:
  33.        - execl, execle and execlp are called when the number of
  34.          arguments is known in advance, whereas execv, execve
  35.          and execvp take an argument vector.
  36.  
  37.        - execl, execv, execle and execve are called with the full
  38.          path name of the program to be run, whereas execlp and
  39.          execvp are called with a filename that is searched on
  40.          the user's search path and that may be extended with
  41.          the filename extensions ".ttp", ".tos" and ".prg".
  42.  
  43.        - execl, execv, execlp and execvp pass the parent's
  44.          environment to the new process, whereas execle and
  45.          execve take a pointer to an environment vector as
  46.          their final argument.
  47.  
  48.        The last argument to the execl, execle  and  execlp  func-
  49.        tions should be a NULL pointer.
  50.  
  51.        An  argument  vector  argv  as  used  in execv, execve and
  52.        execvp is a pointer to a null-terminated array of  charac-
  53.        ter  pointers  to null-terminated character strings. These
  54.        strings constitute the argument list to be made  available
  55.        to  the new process.  By convention, at least one argument
  56.        must be present in this array, and the  first  element  of
  57.        this array should be the name of the executed program. For
  58.        execv and execve this is the last component  of  the  path
  59.        argument; for execvp this is the file argument.
  60.  
  61.  
  62.  
  63.  
  64. MiNT docs 0.1              3 March 1993                         1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. EXEC(3)             MINTLIB LIBRARY FUNCTIONS             EXEC(3)
  71.  
  72.  
  73.        The  environment  vector envp as used in execle and execve
  74.        is also a pointer to a null-terminated array of  character
  75.        pointers  to  null-terminated  strings. These strings pass
  76.        information to the new  process  which  are  not  directly
  77.        arguments  to the command.  If envp is NULL, a copy of the
  78.        parent process' environment is passed.
  79.  
  80.        Signals set to the default action (SIG_DFL) in the calling
  81.        process  image  are  set  to the default action in the new
  82.        process.  Signals set to be ignored (SIG_IGN) by the call-
  83.        ing process are ignored by the new process. Signals set to
  84.        be caught by the calling process are reset to the  default
  85.        action  in  the  new process. Signals set to be blocked in
  86.        the calling process remain blocked  in  the  new  process,
  87.        regardless of changes to the signal action.
  88.  
  89. R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
  90.        These  functions  returns  to  the calling process only on
  91.        failure, for instance if the program called could  not  be
  92.        found,  if  it was not executable, or if not enough memory
  93.        was available, in which case -1 is returned and  errno  is
  94.        set to indicate the error.
  95.  
  96. E✓EX✓XA✓AM✓MP✓PL✓LE✓ES✓S
  97.          This will execute the program /bin/date or fail:
  98.        execl("/bin/date", "date", NULL);
  99.  
  100.          This will search the program sh and then execute it;
  101.          it will fail only if sh, sh.tos, sh.ttp and sh.prg
  102.          could not be found:
  103.        execlp("sh", "sh", "-c", commandline, NULL);
  104.  
  105.          This will call /bin/test using an already constructed
  106.          argument vector and an already constructed environment
  107.          vector, and fail if /bin/test could not be found:
  108.        execve("/bin/test", my_argv, my_envp);
  109.  
  110. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  111.        f✓fo✓or✓rk✓k(✓(3✓3)✓),✓, s✓si✓ig✓gn✓na✓al✓l(✓(3✓3)✓),✓, t✓tf✓fo✓or✓rk✓k(✓(3✓3)✓),✓, v✓vf✓fo✓or✓rk✓k(✓(3✓3)✓),✓, _✓_s✓sp✓pa✓aw✓wn✓nv✓ve✓e(✓(3✓3)✓)
  112.  
  113. N✓NO✓OT✓TE✓ES✓S
  114.        When  MiNT is not active, these library calls call a child
  115.        process and then _exit after the child has finished;  only
  116.        when  MiNT  is active, the current process is truly trans-
  117.        formed into a new one.
  118.  
  119.        On Un*x, execve is a system call, while the rest of  these
  120.        calls  are  library routines. Under MiNT, it's all done in
  121.        the library.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. MiNT docs 0.1              3 March 1993                         2
  131.  
  132.  
  133.